<template>
  <div class="school">
    <h2>学校名称：{{ name }}</h2>
    <h2>学校地址：{{ address }}</h2>
  </div>
</template>

<script>
export default {
  name: "SchoolInfo",
  data() {
    return {
      name: "石大",
      address: "青岛",
    };
  },
  mounted() {
    console.log("School", this);
    this.$bus.$on("hello", (data) => {
      console.log("我是School，已收到数据", data);
    });
  },
  beforeDestroy() {
    // 若销毁组件，应该取消绑定的全局自定义事件
    this.$bus.$off("hello");
  },
};
</script>
<style scoped lang="less">
.school {
  background-color: skyblue;
  padding: 5px;
}
</style>